﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class getImageList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        Response.Charset = "utf-8";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");

        string selectedLocation = "";
        string selectedYear = "";

        string resultXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\n";
        resultXml += "<ImageList>" + "\n";

        if (Request.QueryString.Count > 0)
        {
            selectedLocation = Request.QueryString[0].ToString().Trim();
            selectedYear = Request.QueryString[1].ToString().Trim();// +"-01-01";
        }

        string queryString = "";
        if (selectedLocation != "" && selectedYear != "")
        {
            queryString = "select * from DISTRICT_IMAGE_SP_MAP where distid = '" + selectedLocation + "' and IMAGEYEAR ='" + selectedYear + "'";
        }
        else
        {
            queryString = "select * from DISTRICT_IMAGE_SP_MAP";
        }
        DataSet ds = AccessDatabase.Query(queryString);
        DataTable dt = ds.Tables[0];
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            resultXml += "<Image id = '" + dt.Rows[i][2].ToString().Trim() + "' name = '" + dt.Rows[i][3].ToString() + "' distid='" + dt.Rows[i][0].ToString().Trim() + "'/>" + "\n";
        }
        resultXml += "</ImageList>" ;
        Response.Write(resultXml);
    }
}
